package com.mz.ozy.mvp.presenter;


import android.app.Activity;
import android.content.Context;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.FriendBean;
import com.mz.ozy.bean.MyBounsBean;
import com.mz.ozy.bean.MyBounsRecodeBean;
import com.mz.ozy.bean.NewBonusBean;
import com.mz.ozy.bean.NewBonusDetailBean;
import com.mz.ozy.bean.NewBonusDonateBean;
import com.mz.ozy.bean.NewGQBean;
import com.mz.ozy.bean.NewResponeBean;
import com.mz.ozy.bean.PronotionBean;
import com.mz.ozy.mvp.model.MeModel;
import com.mz.ozy.mvp.view.MyBonusContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import java.util.List;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class MyBounsPresenter extends BasePresenterImpl<MyBonusContract.View> implements MyBonusContract.Presenter {

    private MeModel mModel;


    public MyBounsPresenter() {
        mModel = new MeModel();
    }

    @Override
    public void info(Activity activity, int type) {
        mModel.getMybounsInfo(activity, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<MyBounsBean>(mView) {
                    @Override
                    public void onSuccesss(MyBounsBean bean) {
                        mView.getInfoSuccess(bean);
                    }
                });
    }

    @Override
    public void vipUpSh(Context context, int type) {


        mModel.getVipUpSh(context, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<FriendBean>(mView) {
                    @Override
                    public void onSuccesss(FriendBean bean) {
                        mView.getVipUpShSuccess(bean);
                    }
                });
    }

    @Override
    public void vipUpDataSh(Context context, String id, int type) {
        mModel.getVipUpDataInfo(context, id, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<PronotionBean>(mView) {
                    @Override
                    public void onSuccesss(PronotionBean bean) {
                        mView.getVipUpDataInfoSuccess(bean);

                    }
                });
    }

    @Override
    public void recode(Context context, String page, String url) {
        mModel.getMybounsRecode(context, page, url)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<MyBounsRecodeBean>(mView) {
                    @Override
                    public void onSuccesss(MyBounsRecodeBean bean) {
                        mView.getInfoRecode(bean);
                    }
                });
    }

    @Override
    public void newBonus(Context context) {
        mModel.newBonus(context)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewBonusBean>(mView) {
                    @Override
                    public void onSuccesss(NewBonusBean bean) {
                        mView.newBonusSuccess(bean);
                    }
                });
    }

    @Override
    public void newBonusDetail(Context context, String page, String type) {
        mModel.newBonusDetail(context, page, type)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewBonusDetailBean>(mView) {
                    @Override
                    public void onSuccesss(NewBonusDetailBean bean) {
                        mView.newBonusDetailSuccess(bean);
                    }
                });
    }

    @Override
    public void newBonusDonate(Context context, String amount, String exUid, String payPwd) {
        mModel.newBonusDonate(context, amount, exUid, payPwd)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewBonusDonateBean>(mView) {
                    @Override
                    public void onSuccesss(NewBonusDonateBean bean) {
                        mView.newBonusDonateSuccess(bean);
                    }
                });
    }

    @Override
    public void newGQ(Context context, String page) {
        mModel.newGQ(context, page)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<NewGQBean>(mView) {
                    @Override
                    public void onSuccesss(NewGQBean bean) {
                        mView.newGQSuccess(bean);
                    }
                });
    }
}
